package com.atguigu.gmall;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: 李旭
 * @create: 2021-08-31 15:17
 **/
public class ThreadPoolDemo {

    //线程池
    public static void main(String[] args) {
        //练习 或学习
        //new Thread().start();

        ThreadPoolExecutor threadPoolExecutor =
                new ThreadPoolExecutor(
                        5,//核心线程数
                        10,//最大线程数  5
                        5,//存活时间：超出核心线程数的线程的存活时间
                        TimeUnit.MINUTES,//单位
                        new ArrayBlockingQueue(10) //队列
                );
        threadPoolExecutor.execute(() -> {
            System.out.println(Thread.currentThread().getName());
        });
        //pool-1-thread-1

    }
}
